<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改权限菜单')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-authority-edit" th:object="${authority}">
        <input name="id" type="hidden" th:field="*{id}" id="id"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">账号名：</label>
            <div class="col-sm-8">
                <select id="userId" name="userId" class="form-control">
                    <option></option>
                    <option th:each="sysUsers:${sysUsers}" th:value="${sysUsers.userId }"
                            th:text="${sysUsers.userName }" th:field="*{userId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">公司：</label>
            <div class="col-sm-8">
                <select id="compID" name="compID" class="form-control" th:onchange="getbumen(this.value)">
                    <option th:each="companys:${companys}" th:value="${companys.compID }"
                            th:text="${companys.compAbbr }" th:field="*{compID}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门：</label>
            <div class="col-sm-8">
                <select id="depId" name="depId" class="form-control select2-multiple" multiple>
                    <option th:each="departments:${departments}" th:value="${departments.depID }"
                            th:text="${departments.title }" selected></option>
                </select>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script type="text/javascript">
    var prefix = ctx + "sysAuthority";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-user-edit").serializeArray();
            var id = $("#id").val();
            var userId = $("#userId").val();
            var compID = $("#compID").val();
            var depId = $("#depId").val();
            data.push({"name": "id", "value": id});
            data.push({"name": "userId", "value": userId});
            data.push({"name": "compID", "value": compID});
            data.push({"name": "depIds", "value": depId});
            $.operate.save(prefix + "/edit", data);
        }
    }

</script>
</body>
</html>
